package com.mydemo.ssm.controller;



import com.alibaba.fastjson.JSON;
import com.mydemo.ssm.model.UserModel;
import com.mydemo.ssm.service.IUserService;
import org.aspectj.apache.bcel.classfile.Method;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

@Controller
@RequestMapping("/user")
public class UserController {

    @Autowired
    private IUserService userService;



    @GetMapping(path = "/findAll" )
    @ResponseBody
    public String findAll() throws Exception {
        List<UserModel> userList = userService.getUserList();
        return JSON.toJSONString(userList);
    }
    @GetMapping(path = "/" )
    public String index() throws Exception {

        return "index";
    }
}
